package com.site.dao.impl.dining;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

import com.site.dao.dining.RestaurantMenuDao;
import com.site.dto.dining.RestaurantMenuBizBean;
import com.site.model.dining.RestaurantMenuInfo;
import com.site.util.base.dao.BaseDaoImpl;
import com.site.util.extremetable.QueryPage;

/**
 * 餐厅菜单
 * @author jack
 *
 */
@Repository
public class RestaurantMenuDaoImpl extends BaseDaoImpl implements RestaurantMenuDao {

	@Override
	public List<RestaurantMenuInfo> getRestaurantMenus(QueryPage queryPage,
			RestaurantMenuBizBean restaurantMenuBizBean) {
		String hql = "from RestaurantMenuInfo where 1 = 1 ";
		Map<String ,Object> map = new HashMap<String, Object>();
		if(null != restaurantMenuBizBean){
			if(restaurantMenuBizBean.getRid() != null){
				hql +=" and rid = :rid";
				map.put("rid", restaurantMenuBizBean.getRid());
			}
			if(!StringUtils.isEmpty(restaurantMenuBizBean.getName())){
				hql +=" and name = :name";
				map.put("name", restaurantMenuBizBean.getName());
			}
		}
		if(null == queryPage){
			return findByHQL(hql, map);
		} else {
			return findByHQL(queryPage, hql, map, false);
		}
	}
}
